<script setup>
import { ref, defineOptions } from 'vue'
import TopTitle from "@/components/TopTitle.vue"
import { Manfree } from '@/api/getAxios_2.ts'

const redMsg = ref([])
const personGoods = ref([])
const bookres = ref([])
const goodProduct = ref([])
const wellendbook = ref([])
const sicker = ref([])
Manfree().then((res) => {
    console.log(res);
    redMsg.value = res.data.data[0].list
    personGoods.value = res.data.data[1].list
    bookres.value = res.data.data[2].list
    goodProduct.value = res.data.data[3].list
    wellendbook.value = res.data.data[4].list
    sicker.value = res.data.data[5].list
})

//***************************************** */

// 万和亿的换算
const getNumType = (num) => {
    if (num / 10000 >= 10000) {
        return (num / 100000000).toFixed(1) + '亿人气值'
    } else {
        return (num / 10000).toFixed(1) + '万人气值'
    }
}

//***************************************** */

</script>
<template>
    <div class="box">
        <TopTitle :flag="true" name="免费"></TopTitle>
        <div class="sus-adventure">
            <h1 class="recommend">
                <span>精品红文</span>
            </h1>
            <ul>
                <li v-for="item in redMsg" @click="$router.push(`/BookInfo?storyId=${item.storyId}`)">
                    <img :src="item.cover" alt="">
                    <p>{{ item.storyName }}</p>
                </li>
            </ul>
        </div>
        <div class="city-msg">
            <h1 class="recommend">
                <span>人气好书</span>
            </h1>
            <ul>
                <li v-for="item in personGoods" @click="$router.push(`/BookInfo?storyId=${item.storyId}`)">
                    <div class="coverImg">
                        <img :src="item.cover" alt="">
                    </div>
                    <div class="msg">
                        <p class="name">{{ item.storyName }}</p>
                        <p class="detail">{{ item.introduce }}</p>
                        <p class="type">
                            <span class="author-type">{{ item.author }} | {{ item.type }}</span>
                            <span class="fireValue">{{ getNumType(item.fireValue) }}</span>
                        </p>
                    </div>
                </li>
            </ul>
        </div>
        <div class="sus-adventure">
            <h1 class="recommend">
                <span>书荒热荐</span>
            </h1>
            <ul>
                <li v-for="item in bookres" @click="$router.push(`/BookInfo?storyId=${item.storyId}`)">
                    <img :src="item.cover" alt="">
                    <p>{{ item.storyName }}</p>
                </li>
            </ul>
        </div>
        <div class="city-msg">
            <h1 class="recommend">
                <span>口碑佳作</span>
            </h1>
            <ul>
                <li v-for="item in goodProduct" @click="$router.push(`/BookInfo?storyId=${item.storyId}`)">
                    <div class="coverImg">
                        <img :src="item.cover" alt="">
                    </div>
                    <div class="msg">
                        <p class="name">{{ item.storyName }}</p>
                        <p class="detail">{{ item.introduce }}</p>
                        <p class="type">
                            <span class="author-type">{{ item.author }} | {{ item.type }}</span>
                            <span class="fireValue">{{ getNumType(item.fireValue) }}</span>
                        </p>
                    </div>
                </li>
            </ul>
        </div>
        <div class="sus-adventure">
            <h1 class="recommend">
                <span>经典完本</span>
            </h1>
            <ul>
                <li v-for="item in wellendbook" @click="$router.push(`/BookInfo?storyId=${item.storyId}`)">
                    <img :src="item.cover" alt="">
                    <p>{{ item.storyName }}</p>
                </li>
            </ul>
        </div>
        <div class="city-msg city-msg1">
            <h1 class="recommend">
                <span>网文重度患者</span>
            </h1>
            <ul>
                <li v-for="item in sicker" @click="$router.push(`/BookInfo?storyId=${item.storyId}`)">
                    <div class="coverImg">
                        <img :src="item.cover" alt="">
                    </div>
                    <div class="msg">
                        <p class="name">{{ item.storyName }}</p>
                        <p class="detail">{{ item.introduce }}</p>
                        <p class="type">
                            <span class="author-type">{{ item.author }} | {{ item.type }}</span>
                            <span class="fireValue">{{ getNumType(item.fireValue) }}</span>
                        </p>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</template>

<style scoped lang='less'>
.box {
    height: 100vh;
    overflow: scroll;
    &::-webkit-scrollbar {
        display: none;
    }
}

.sus-adventure {
    height: 77vw;
    background-color: #fff;
    margin-bottom: 10px;

    h1 {
        text-align: center;
        font-weight: bold;
        font-size: 22px;
        padding: 10px 0px 5px;
        position: relative;
    }

    ul {
        display: flex;
        flex-wrap: wrap;

        li {
            width: 28vw;
            height: 37vw;
            margin: 30px 10px;
            border-radius: 10px;
            box-shadow: 0px 15px 7px -11px rgba(0, 0, 0, .3);


            img {
                border-radius: 10px;
                width: 100%;
                height: 100%;
            }

            p {
                display: -webkit-box;
                text-align: center;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
                overflow: hidden;
                text-overflow: ellipsis;
            }

        }
    }
}

.city-msg {
    height: 158vw;
    background-color: #fff;
    margin-bottom: 15px;

    h1 {
        text-align: center;
        font-weight: bold;
        font-size: 22px;
        padding: 20px 0px;
        position: relative;
    }

    ul {
        display: flex;
        flex-direction: column;

        li {
            padding: 10px;
            height: 40vw;
            display: flex;

            .coverImg {

                border-radius: 10px;
                width: 30vw;
                height: 40vw;

                img {
                    border-radius: 10px;
                    box-shadow: 0px 15px 7px -11px rgba(0, 0, 0, .3);

                    width: 100%;
                    height: 100%;
                }
            }

            .msg {
                text-align: center;
                display: flex;
                flex-direction: column;
                justify-content: space-around;
                width: 68vw;
                margin-left: 10px;

                .name {
                    font-size: 18px;

                }

                .detail {
                    display: -webkit-box;
                    text-align: center;
                    -webkit-line-clamp: 2;
                    -webkit-box-orient: vertical;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    color: #939296;
                    font-size: 14px;
                }

                .type {

                    color: #939296;
                    font-size: 12px;

                    .fireValue {
                        margin-left: 20px;
                        color: #ccae59;
                    }
                }


            }

        }
    }
}

.city-msg1 {
    height: 300vw;
}
</style>